<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>

var ctx = document.createElement('canvas').getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = 100;
canvas2.height = 100;
var ctx2 = canvas2.getContext('2d');

test(function(t) {   
    ctx.beginPath();
    ctx.strokeStyle = 'green';
    ctx.lineWidth = 100;
    ctx.strokeRect(50, 0, 100, 100);
    assert_array_equals(ctx.getImageData(2, 1, 1, 1).data.slice(0,3), [0, 128, 0]);
}, "Verify the correct behaviour of canvas.strokeRect() with solid green");

test(function(t) {
    ctx.clearRect(0, 0, 100, 100);   
    ctx2.fillStyle = 'green';
    ctx2.fillRect(0, 0, 100, 100);
    var pattern = ctx.createPattern(canvas2, 'repeat');
    ctx.strokeStyle = 'pattern';
    ctx.lineWidth = 100;
    ctx.strokeRect(50, 0, 100, 100);
    assert_array_equals(ctx.getImageData(2, 1, 1, 1).data.slice(0,3), [0, 128, 0]);   
}, "Verify the correct behaviour of canvas.strokeRect() with a pattern");

test(function(t) {
    ctx.clearRect(0, 0, 100, 100);    
    var gradient = ctx.createLinearGradient(0, 0, 0, 100);
    gradient.addColorStop(0, "green");
    gradient.addColorStop(1, "green");
    ctx.strokeStyle = 'gradient';
    ctx.lineWidth = 100;
    ctx.strokeRect(50, 0, 100, 100);
    assert_array_equals(ctx.getImageData(2, 1, 1, 1).data.slice(0,3), [0, 128, 0]);
}, "Verify the correct behaviour of canvas.strokeRect() with a gradient");

test(function(t) {
    ctx.clearRect(0, 0, 100, 100);    
    ctx.strokeStyle = 'red';
    ctx.lineWidth = 2;
    ctx.strokeRect(0, 0, 0, 0);
    assert_array_equals(ctx.getImageData(0, 0, 1, 1).data.slice(0,3), [0, 0, 0]);
}, "Verify the correct behaviour of canvas.strokeRect() with height = width = 0 and lineWidth = 2");

test(function(t) {
    ctx.shadowOffsetX = 5;
    ctx.shadowOffsetY = 5;
    ctx.shadowColor = 'blue';
    ctx.strokeStyle = 'red';
    ctx.lineWidth = 2;
    ctx.strokeRect(0, 0, 0, 0);
    assert_array_equals(ctx.getImageData(0, 0, 1, 1).data.slice(0,3), [0, 0, 0]);
}, "Verify the correct behaviour of canvas.strokeRect()  with height = width = 0, lineWidth = 2, and shadow");

</script>
</body>
